package com.xy.biz.fd.strategy.impl;

import com.xy.biz.fd.strategy.RepositoryFilterStrategy;
import com.xy.biz.fd.domain.DocumentPermissions;
import com.xy.biz.fd.domain.bo.RepositoryBO;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

import static com.xy.biz.fd.domain.DocumentPermissions.PREVIEW;

/**
 * @author Greekn Zhang
 * @date 2021/5/12 11:22
 * @description
 */
@Service(RepositoryFilterStrategy.REPOSITORY_FILTER + PREVIEW)
public class RepositoryFilterPreview implements RepositoryFilterStrategy {
    @Override
    public List<RepositoryBO> filter(List<RepositoryBO> userRepositoryBOS) {
        //预览权限
        userRepositoryBOS = userRepositoryBOS.stream().filter(repo ->
                DocumentPermissions.hasPreview(repo.getPermission())
        ).collect(Collectors.toList());
        return userRepositoryBOS;
    }
}
